<template>
  <view>
    <view class="pt-14 w100 rowsc rowsm mb-20">
      <view class="fs-24 col888">基础劳动积分上限：<text class="fs-28" style="color: #FF9934;">{{allMax}}</text>  我已获得积分：<text class="fs-28" style="color: #FF9934;">{{allUserScore}}</text> </view>
    </view>
    
    <view class="w100 pl-24 pr-24">
      <view class="w100 p-all-30 br-10 rowscl mb-20" style="background-color: #F7F6FA;" v-for="(item,index) in list" :key="index">
        <view class="w100 rowsb rowsm mb-20">
          <view class="fs-28 col333 fw-b">{{item.name}}</view>
          <view class="w-126 h-50 br-25 rowsc rowsm colfff fs-24 fw-b" style="background: linear-gradient(to bottom,#4897FF,#4878FF);" @click="goSubmit(item.type,item.name)">填报</view>
        </view>
        <view class="w100 rowsb rowsm">
          <view class="fs-24 w-420 col888">
            <!-- （已获得{{item.userPosition}}积分/上限{{item.maxPoints}}积分） -->
            {{item.content}}
          </view>
          <view class="fs-24 w-150" style="color: #FF9934;white-space: nowrap;">
            <!-- （{{item.points}}积分/次） -->
            已获得{{item.userPosition}}积分
          </view>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
  export default {
    data() {
      return {
        list:[],
        allMax:0,
        allUserScore:0,
        total:0,
        limit: {
          pageNum: 1,
          pageSize: 10
        },
      };
    },
    onLoad() {
      
    },
    onShow() {
      this.getList()
    },
    onReachBottom() {
      if (this.list.length < this.total) {
        this.limit.pageNum++;
        this.getList()
      }
    },
    onPullDownRefresh() {
      this.limit.pageNum = 1
      this.getList()
    },
    methods:{
      goSubmit(i,title){
        if(i == 1 || i == 2 || i == 3 || i == 9 || i == 10 || i == 11) {
          this.$tools.goNext(`/pagesCopy/submitWork/weekWork?type=${i}&title=${title}`)
        }
        if(i == 4) {
          this.$tools.goNext(`/pagesCopy/submitWork/workSavour?type=${i}&title=${title}`)
        }
        if(i == 5) {
          this.$tools.goNext(`/pagesCopy/submitWork/university?type=${i}&title=${title}`)
        }
        if(i == 6) {
          this.$tools.goNext(`/pagesCopy/submitWork/internet?type=${i}&title=${title}`)
        }
        if(i == 7) {
          this.$tools.goNext(`/pagesCopy/submitWork/speech?type=${i}&title=${title}`)
        }
        if(i == 8) {
          this.$tools.goNext(`/pagesCopy/submitWork/example?type=${i}&title=${title}`)
        }
      },
      getList(){
        this.$tools.axiosFromToken('POST',`proldconfig/list?pageNum=${this.limit.pageNum}&pageSize=${this.limit.pageSize}`,{},'加载中').then(res => {
          if(res.code != 200) return this.$tools.showtt(res.msg)
           this.total = res.total
            if (this.limit.pageNum == 1) {
              this.list = res.rows;
            } else {
              this.list = [...this.list, ...res.rows];
            }
          // this.$set(this.list,0,[...rows])
        })
        this.$tools.axiosFromToken('POST','proldconfig/listByUser',{},'加载中').then(res => {
          if(res.code != 200) return this.$tools.showtt(res.msg)
          let {data:{userPoints,countPoints}} = res
          this.allUserScore = userPoints
          this.allMax = countPoints
        })
      }
    },
    computed:{
      // allMax(){
      //   let i = 0
      //   this.list.forEach(item => {
      //     i += +item.maxPoints
      //   })
      //   return i
      // },
      // allUserScore(){
      //   let i = 0
      //   this.list.forEach(item => {
      //     i += +item.userPosition
      //   })
      //   console.log(i)
      //   return i
      // }
    }
  }
</script>

<style lang="scss">
page {
  background-color: #fff;
}
</style>
